/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-05-07
 * Time: 23:02
 */
public enum TestEnum {
/*    RED,BLACK,GREEN,WHITE;*/
    RED(1,"红色"),BLACK(2,"黑色"),
    GREEN(3,"绿色"),WHITE(4,"白色");
    public String color;
    public int ordinal;
    private TestEnum(int ordinal,String color) {
        //
        this.color = color;
        this.ordinal = ordinal;
    }

    public static void main(String[] args) {
        System.out.println(RED.compareTo(WHITE));
    }

    public static void main4(String[] args) {
        TestEnum val = TestEnum.valueOf("RED");
        System.out.println(val);
        TestEnum val1 = TestEnum.valueOf("RED2");
        System.out.println(val1);
    }

    public static void main3(String[] args) {
        TestEnum[] testEnums = TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i].ordinal());
        }
    }

    public static void main2(String[] args) {
        TestEnum[] testEnums = TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i]);
        }
    }


    public static void main1(String[] args) {
        TestEnum testEnum = RED;
        switch(testEnum) {
            case BLACK:
                System.out.println("BLACK");
                break;
            case GREEN:
                System.out.println("GREEN");
                break;
            case WHITE:
                System.out.println("WHITE");
                break;
            case RED:
                System.out.println("RED");
                break;

        }
    }
}
